Gnc.DepartmentTreeSelect = function () {
    Gnc.DepartmentTreeSelect.superclass.constructor.call(this);
    this.set({
        border: 1,
        emptyText: '请选择...',
        parentField:'ParentTaskUID',
        valueField:'UID',
        textField:'Name'
    });
};
mini.extend(Gnc.DepartmentTreeSelect, mini.TreeSelect, {
    //title:"部门树形下拉框",
    uiCls: "gnc-departmenttreeselect",
    url: bootPATH+GNC.Uri.GetDepartments.replace('js=1','js=2')+'?queryType=loadByAll',
    showClose:true,
    expandOnLoad: true,
    selectedItem: null,
    autoLoad: false,
    loaded:false,
    _create: function () {
        Gnc.DepartmentTreeSelect.superclass._create.call(this);
        this.on('closeclick',function(e){
            var obj = e.sender;
            this.setNameValue('','');
            this.fire('departmentCleared');
        },this);
         if(this.autoLoad){
            this.reload();
        }
        this.on('beforeshowpopup',function(){
            if(this.loaded) return;
            this.reload();
        },this);
        this.on('valuechanged',function(record){
            var rec = {selected:{id:record.value}};
            this.selectedItem = rec;
            this.fire('departmentSelected',rec);
        },this);
    },
    reload:function()
    {
        this.load(this.url);
        this.loaded=true;
    },
    removeAll:function(){
        this.setNameValue('','');
        this.setData([]);
    },
    setValue:function(value){
        Gnc.DepartmentTreeSelect.superclass.setValue.call(this,value);        
    },
    setNameValue:function(name,value){
        this.setValue(value);
        this.setText(name);
    }
});
mini.regClass(Gnc.DepartmentTreeSelect, "Gnc.DepartmentTreeSelect");	